package org.example.util;

import io.jsonwebtoken.security.Keys;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class KeyUtil {
    public static String generateKey() {
        byte[] keyBytes = Keys.secretKeyFor(io.jsonwebtoken.SignatureAlgorithm.HS256).getEncoded();
        return Base64.getEncoder().encodeToString(keyBytes);
    }

    public  static  String Md5(String str) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(str.getBytes());
        byte[] digest = md.digest();
        String string = Base64.getEncoder().encodeToString(digest);
        return string;
    }
}
